# $Id$
# Maintainer: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>
# Contributor: Corrado Primier <bardo@aur.archlinux.org>

pkgname=rtkit
pkgver=0.11+6+g417bb7d
pkgrel=1
pkgdesc="Realtime Policy and Watchdog Daemon"
arch=(i686 x86_64)
url="https://github.com/heftig/rtkit"
license=(GPL3 'custom:BSD')
depends=(dbus polkit systemd)
makedepends=(git)
install=rtkit.install
_commit=417bb7d79b39ebf7dc799f2b4da62e3996b65542  # master
source=("git+https://github.com/heftig/rtkit#commit=$_commit")
sha256sums=('SKIP')

pkgver() {
  cd $pkgname
  git describe --tags | sed 's/^v//;s/-/+/g'
}

prepare() {
  cd $pkgname
  ./autogen.sh
}

build() {
  cd $pkgname
  ./configure \
    --prefix=/usr \
    --sbindir=/usr/bin \
    --sysconfdir=/etc \
    --libexecdir=/usr/lib/$pkgname \
    --with-systemdsystemunitdir=/usr/lib/systemd/system
  make

  ./rtkit-daemon --introspect > org.freedesktop.RealtimeKit1.xml
}

package() {
  cd $pkgname
  make DESTDIR="$pkgdir" install

  install -Dm644 org.freedesktop.RealtimeKit1.xml \
    "$pkgdir/usr/share/dbus-1/interfaces/org.freedesktop.RealtimeKit1.xml"

  install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
  sed -ne '4,25p' rtkit.c >"$pkgdir/usr/share/licenses/$pkgname/COPYING"
}
